package com.example.lucky.draw.server.repository;

import com.example.lucky.draw.server.protocol.po.Activity;
import org.springframework.data.domain.Page;
import org.springframework.data.domain.Pageable;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.stereotype.Repository;

import java.time.LocalDateTime;
import java.util.List;

@Repository
public interface ActivityRepository extends JpaRepository<Activity, Long> {
    //如果需要根据活动名称和活动状态并根据Sort进行升序排序查询
    List<Activity> findByNameAndStatusOrderBySortAsc(String name,Integer status);
    //根据活动ID，查询ID在39-42之间的活动
    List<Activity> findByIdBetween(Long start, Long end);

    //获取状态为已启用，并且过期时间小于当前时间的活动
    Page<Activity> findByStatusAndEndTimeBefore(Integer status, LocalDateTime currentTime, Pageable pageable);

    List<Activity> findByStatusEquals(Integer status);
}
